package com.itheima.web;

import com.itheima.pojo.Brand;
import com.itheima.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/SelectAllServlet")
public class SelectAllServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //调用业务层的selectAll方法

        //创建业务层对象
        BrandService service = new BrandService();
        //调用业务层的selectAll的方法
        List<Brand> brands = service.selectAll();

        //将对象数据存入到request域中
        request.setAttribute("brands",brands);
        

        //请求转发到jsp页面展示
        request.getRequestDispatcher("/brand.jsp").forward(request,response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}